import sys
from sqlalchemy import create_engine
import time

from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
 
 
# 创建对象的基类:
Base = declarative_base()
# 创建引擎,初始化数据库连接:
engine = create_engine('mysql+pymysql://root:123456@127.0.0.1:3307/tinyms')
# 创建session对象
DBSession = sessionmaker(bind=engine)
# 创建session
session = DBSession()
# sql 语句
sql = 'select * from cms_article '
# 执行sql
result = session.execute(sql)   
print(result)
alldata = result.fetchall()  
print(alldata)
 
session.commit()
session.close()